package com.frx.common.map;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IDEA
 *
 * @author: xrf
 * @Date: 2019/11/19
 * @Time: 14:20
 */
public class TestHashMap {

    public static void main(String[] args){
        String str = new String();
        System.out.println(str);
        System.out.println("--------");
        Map<Obj,Integer> map = new HashMap<>(16);
        ArrayList list = new ArrayList();
        Obj a = new Obj(1);
        System.out.println(map.put(a,1));
        System.out.println(map.put(new Obj(2),3));
        System.out.println(map.put(new Obj(1),1));
        System.out.println(map.put(new Obj(1),2));

        System.out.println("--------------");
        System.out.println(map);
        System.out.println(map.get(a));
    }


    static class Obj{
        int val;
        Obj(int val){
            this.val = val;
        }
        @Override
        public int hashCode() {
            return val;
        }

        @Override
        public boolean equals(Object obj) {
            return true;
        }
    }
}
